Fix calling AI functions with no parameters#221
Merged
heyitsaamir merged 2 commits intomainfrom Nov 24, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where AI functions with no parameters would fail when wrapped with plugin hooks. The issue occurred because the wrapped function always expected a positional argument (params), but functions with parameter_schema=None are called without arguments, causing Python to throw a TypeError.
Key Changes
- Modified
_wrap_function_handlerto acceptparameter_schemaparameter and return a no-argument lambda wrapper whenparameter_schema is None - Added comprehensive test coverage for no-parameter functions with plugins
- Fixed unrelated documentation error in
HttpPluginexample
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/ai/src/microsoft/teams/ai/chat_prompt.py | Added parameter_schema parameter to _wrap_function_handler and implemented lambda wrapper for no-parameter functions to fix the bug |
| packages/ai/tests/test_chat_prompt.py | Added new test case test_function_with_no_parameters_wrapped_with_plugins to verify the fix works correctly with plugins |
| packages/apps/src/microsoft/teams/apps/http_plugin.py | Removed invalid app_id parameter from documentation example (unrelated documentation fix) |
Comments suppressed due to low confidence (1)
packages/ai/src/microsoft/teams/ai/chat_prompt.py:210
- The docstring is missing documentation for the newly added
parameter_schemaparameter. Please add it to the Args section:
Args:
original_handler: The original function handler to wrap
function_name: Name of the function for plugin identification
parameter_schema: Type schema for function parameters, or None if function has no parameters
Returns:
Wrapped handler that includes plugin hook execution """
Wrap a function handler with plugin before/after hooks.
Creates a new handler that executes plugin hooks before and after
the original function, allowing plugins to modify parameters and results.
Args:
original_handler: The original function handler to wrap
function_name: Name of the function for plugin identification
Returns:
Wrapped handler that includes plugin hook execution
"""
lilyydu
approved these changes
Nov 24, 2025
Merged
heyitsaamir
added a commit
that referenced
this pull request
Dec 9, 2025
## Release 2.0.0a7 ### Changes - update react and react-dom to 19.2.1 (#233) - Move to microsoft_teams namespace (#226) - Simplify setting http response after activity processing (#218) - Add TeamsChannelAccount type for Teams-specific APIs (#230) - Updating mcpplugin reference in README.md (#229) - Bring back bot builder example (#225) - Fix choices_data alias to use "choices.data" instead of "choicesData" (#224) - [docs] botbuilder package README fixes (#223) - Fix calling AI functions with no parameters (#221)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We wrap our AI functions such that we can call the AI plugins etc.
But if there are no parameters, we call the function like
foo(). However, the wrapped function always has 1 positional argument. So python throws. This fixes that bug.PR Dependency Tree
This tree was auto-generated by Charcoal